package com.link.play.fit.ai.ui.dialog

import android.app.Activity
import android.app.AlertDialog
import android.view.LayoutInflater
import com.link.play.fit.ai.R
import com.link.play.fit.ai.databinding.DialogWeightControlBinding

class WeightControlDialog(
    val activity: Activity
) {
    private val TAG = "CongratulationDialog"
    private val dialog = AlertDialog.Builder(activity).create()
    private val binding = DialogWeightControlBinding.inflate(LayoutInflater.from(activity))
    fun showDialog(
         nAction:()->Unit,
         yAction:()->Unit
    ) {
        dialog.setView(binding.root)
        dialog.setCanceledOnTouchOutside(true)
        dialog.setCancelable(true)
        dialog.show()

        dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
        val params = dialog?.window?.attributes
//        params?.width = ConstraintLayout.LayoutParams.MATCH_PARENT
//        params?.gravity = Gravity.BOTTOM

        dialog?.window?.attributes = params

        binding.tvN.setOnClickListener {
            nAction.invoke()
            dialog.dismiss()
        }
        binding.tvY.setOnClickListener {
            yAction.invoke()
            dialog.dismiss()
        }
    }
}